#include "FreeRTOS.h"
#include "queue.h"

#include "stm32f411ceu6_task_adc.h"
#include "main.h"
#include "adc.h"

#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>

QueueHandle_t g_adc_queue;   //定义队列

uint32_t buffer1;
uint32_t buffer2;

//申明函数
void adc_init(void);
void adc_task(void);

//定义并初始化结构体
struct AdcInterface adc_interface = {
    .pfinit = adc_init,
    .pftask = adc_task,
};

void adc_init(void)
{
    g_adc_queue = xQueueCreate(1, sizeof(uint32_t));
    buffer1 = malloc();
}
void adc_task(void)
{
    uint32_t ADC_Value = 0;
    HAL_ADC_Start_DMA(&hadc1, &ADC_Value, 1);
}
//adc的DMA中断
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
{
    // if (currentBuffer == 1)
    // {
    //     currentBuffer = 2;
    //     hdma_adc.Instance->M0AR = (uint32_t)buffer2;
    //     osSignalSet(threadAHandle, 0x01);
    // }
    // else
    // {
    //     currentBuffer = 1;
    //     hdma_adc.Instance->M0AR = (uint32_t)buffer1;
    //     osSignalSet(threadAHandle, 0x02);
    // }
}